<?php
ini_set('default_charset', 'utf-8');

define('__ROOT__', dirname(dirname(__FILE__))."/CodeVault/");
define('LIB_PATH', __ROOT__ . 'lib/');
define('DOCTRINE_PATH', __ROOT__ . 'lib/doctrine/lib/');
define('MODELS_PATH', __ROOT__ . 'models/');
define('CONTROLLERS_PATH', __ROOT__ . '/controllers/');
define('APPCODE_PATH', __ROOT__ . 'appcode/');

require_once(DOCTRINE_PATH . 'Doctrine.php');
require_once(LIB_PATH."Smarty.class.php");
require_once(LIB_PATH."fluent/fluent.php");

$folders[] = APPCODE_PATH;
$folders[] = APPCODE_PATH."Enum/";
$folders[] = APPCODE_PATH."Helper/";

foreach($folders as $folder){
    foreach (glob($folder."*.php") as $filename) {
        require_once($filename);
    }
}


spl_autoload_register(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));

$GLOBALS['doctrine_db'] = Doctrine_Manager::connection("mysql://".DB_USER.":".DB_PASSWORD."@".DB_HOST."/".DB_NAME);
$GLOBALS['doctrine_manager'] = Doctrine_Manager::getInstance();
//$GLOBALS['doctrine_manager']->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$GLOBALS['doctrine_manager']->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);

Doctrine_Core::setModelsDirectory(MODELS_PATH);

?>